home *** CD-ROM | disk | FTP | other *** search
/ Cracking 1 / Cracking I..iso / Příklady / 3.Anti-Debugging / Detekce SoftICu / Autoexec / AutoexecDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-07  |  3.3 KB  |  127 lines

  1. // AutoexecDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Autoexec.h"
  6. #include "AutoexecDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CAutoexecDlg dialog
  16.  
  17. CAutoexecDlg::CAutoexecDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CAutoexecDlg::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CAutoexecDlg)
  21.         // NOTE: the ClassWizard will add member initialization here
  22.     //}}AFX_DATA_INIT
  23.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  24.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  25. }
  26.  
  27. void CAutoexecDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.     //{{AFX_DATA_MAP(CAutoexecDlg)
  31.         // NOTE: the ClassWizard will add DDX and DDV calls here
  32.     //}}AFX_DATA_MAP
  33. }
  34.  
  35. BEGIN_MESSAGE_MAP(CAutoexecDlg, CDialog)
  36.     //{{AFX_MSG_MAP(CAutoexecDlg)
  37.     ON_WM_PAINT()
  38.     ON_WM_QUERYDRAGICON()
  39.     ON_BN_CLICKED(IDC_OK, OnOk)
  40.     //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CAutoexecDlg message handlers
  45.  
  46. BOOL CAutoexecDlg::OnInitDialog()
  47. {
  48.     CDialog::OnInitDialog();
  49.  
  50.     // Set the icon for this dialog.  The framework does this automatically
  51.     //  when the application's main window is not a dialog
  52.     SetIcon(m_hIcon, TRUE);            // Set big icon
  53.     SetIcon(m_hIcon, FALSE);        // Set small icon
  54.     
  55.     // TODO: Add extra initialization here
  56.     
  57.     return TRUE;  // return TRUE  unless you set the focus to a control
  58. }
  59.  
  60. // If you add a minimize button to your dialog, you will need the code below
  61. //  to draw the icon.  For MFC applications using the document/view model,
  62. //  this is automatically done for you by the framework.
  63.  
  64. void CAutoexecDlg::OnPaint() 
  65. {
  66.     if (IsIconic())
  67.     {
  68.         CPaintDC dc(this); // device context for painting
  69.  
  70.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  71.  
  72.         // Center icon in client rectangle
  73.         int cxIcon = GetSystemMetrics(SM_CXICON);
  74.         int cyIcon = GetSystemMetrics(SM_CYICON);
  75.         CRect rect;
  76.         GetClientRect(&rect);
  77.         int x = (rect.Width() - cxIcon + 1) / 2;
  78.         int y = (rect.Height() - cyIcon + 1) / 2;
  79.  
  80.         // Draw the icon
  81.         dc.DrawIcon(x, y, m_hIcon);
  82.     }
  83.     else
  84.     {
  85.         CDialog::OnPaint();
  86.     }
  87. }
  88.  
  89. // The system calls this to obtain the cursor to display while the user drags
  90. //  the minimized window.
  91. HCURSOR CAutoexecDlg::OnQueryDragIcon()
  92. {
  93.     return (HCURSOR) m_hIcon;
  94. }
  95.  
  96. void CAutoexecDlg::OnOk() 
  97. {
  98.     CFile File;
  99.     char SIString[] = "winice.exe";
  100.     CString String;
  101.     BOOL SoftICE = FALSE;
  102.     
  103.     if (File.Open("c:\\autoexec.bat",CFile::modeRead) && File.GetLength() != 0)
  104.     {
  105.         BYTE *pMem = new BYTE[File.GetLength()+1];  // alokace pam∞ti
  106.         File.Read(pMem, File.GetLength()+1);  // naΦtenφ souboru do pam∞ti
  107.         
  108.         String = pMem;
  109.         String.MakeLower();  // pro jistotu p°evedeme vÜechna pφsmena na malß 
  110.         
  111.         for (int i = 0; i < String.GetLength()-strlen(SIString); i++) 
  112.         {  // postupnΘ hledßnφ °et∞zce v celΘm souboru
  113.             if (String.Mid(i,strlen(SIString)) == SIString) // byl nalezen   
  114.             {                                     // °et∞zec "winice.exe"?
  115.                 SoftICE = TRUE;
  116.                 break;
  117.             }
  118.         }
  119.         delete []pMem;
  120.     }
  121.  
  122.     if (SoftICE)
  123.         MessageBox("SoftICE nalezen",NULL,MB_OK);
  124.     else
  125.         MessageBox("SoftICE nenalezen",NULL,MB_OK);
  126. }
  127.